package controller

import (
	"ginWork/pkg"
	"github.com/gin-gonic/gin"
	"net/http"
	"time"
)

func UploadOss(c *gin.Context) {

	file, _ := c.FormFile("filename")

	if file.Size > 1024*1024*10 {

		c.JSON(http.StatusOK, gin.H{
			"code": "500",
			"msg":  "oss对象储存上传失败",
		})

		return
	}

	format := time.Now().Format("2006-01-02")

	filename := format + file.Filename

	image := pkg.OssImage(file, filename)

	c.JSON(http.StatusOK, gin.H{
		"code":     "200",
		"filename": filename,
		"image":    image,
		"msg":      "oss对象储存",
	})
}
